<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  function Parent(n){
    this.name = n
  }
  Parent.prototype.show = function(){
    console.log(this.name)
  }

  function Child(){}
  // 将父类的实例，设置为子类的原型对象
  Child.prototype = new Parent("world");
  Child.prototype.constructor = Child;
  // 改写子类的方法，不会影响父类，因为没有操作的同一层原型对象
  Child.prototype.show = function(){
    console.log("hahahahha");
  }

  const p = new Parent("hello")
  console.log(p)
  console.log(p.show)
  p.show();

  const c = new Child();
  console.log(c)
  console.log(c.show)
  c.show();
  
  console.log(c.show === p.show)

  // 继承之前：实例a的__proto__ ----> 构造函数A的prototype
  // 继承之后：实例a的__proto__ ----> 实例p的__proto__ ----> 构造函数P的prototype
</script>
</html>